# coding: utf-8
"""
    Some func
"""

def ip2num(ip):
    """
        Change ip address to a num
        @return: int
    """
    ip, num = ip.split('.')[::-1], 0
    for i in range(4):
        num = num | int(ip[i]) << (8 * i)   
    return num
    
def num2ip(num):
    xor, ip = [0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000], []
    for i in range(4):
        ip.append(str((int(num) & xor[i]) >> (8*i)))
    return '.'.join(ip[::-1])